package com.shuziren.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.shuziren.config.JsonArrayTypeHandler;
import com.shuziren.pojo.entity.vo.InterviewScheduleVo;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
@TableName(value = "interview_schedule" , autoResultMap = true)
public class InterviewSchedule{

    @TableId(type = IdType.AUTO)
    private Integer id;

    @TableField("candidate_id")
    @Min(value = 1, message = "候选人ID 不能小于0")
    private Integer candidateId;

    @TableField("position_id")
    @Min(value = 1, message = "职位ID 不能小于0")
    private Integer positionId;

    @TableField("interview_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date interviewTime;

    @TableField("duration")
    private Integer duration;
    @Min(value = 0, message = "面试官ID 不能小于0")
    @TableField("digital_interviewer_id")

    private Integer digitalInterviewerId;

    @TableField("notes")
    private String notes;

    @TableField("status")
    private Integer status;

    @TableField("created_at")
    private Date createdAt;

    @TableField("updated_at")
    private Date updatedAt;

    @TableField(value = "questionset",typeHandler = JsonArrayTypeHandler.class)
    private List<Integer> questionset;

    @TableField("temporary_passwords")
    private String temporaryPasswords;

    public InterviewScheduleVo toVo() {
        InterviewScheduleVo vo = new InterviewScheduleVo();
        vo.setId(this.id);
        vo.setCandidateId(this.candidateId);
        vo.setPositionId(this.positionId);
        vo.setInterviewTime(this.interviewTime);
        vo.setDuration(this.duration);
        vo.setDigitalInterviewerId(this.digitalInterviewerId);
        vo.setNotes(this.notes);
        vo.setStatus(this.status);
        vo.setCreatedAt(this.createdAt);
        vo.setUpdatedAt(this.updatedAt);
        vo.setTemporaryPasswords(this.temporaryPasswords);
        return vo;
    }
}
